"""
命令行工具：获取币安上 Alpha 空投/Spotlight 相关代币列表

示例：
    python main_alpha.py --quote USDT
    python main_alpha.py --bases-only
    python main_alpha.py --json
"""

import argparse
import json
import logging

from alpha_airdrop_fetcher import (
    get_binance_alpha_airdrop_symbols,
    get_binance_alpha_airdrop_bases,
)


logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)


def main():
    parser = argparse.ArgumentParser(description='获取币安 Alpha 空投/Spotlight 代币列表')
    parser.add_argument('--quote', type=str, default='USDT', help='计价货币（默认 USDT）')
    parser.add_argument('--bases-only', action='store_true', help='仅输出基础币种（BaseAsset）')
    parser.add_argument('--json', action='store_true', help='以 JSON 格式输出')
    args = parser.parse_args()

    quote = args.quote.upper()

    if args.bases_only:
        items = get_binance_alpha_airdrop_bases(quote_asset=quote)
    else:
        items = get_binance_alpha_airdrop_symbols(quote_asset=quote)

    if args.json:
        print(json.dumps(items, ensure_ascii=False))
    else:
        header = '基础币种' if args.bases_only else f'{quote} 计价交易对'
        print(f"\nAlpha 空投/Spotlight 相关（在币安可交易）的{header} 共 {len(items)} 个\n")
        for idx, item in enumerate(items, 1):
            print(f"{idx:2d}. {item}")


if __name__ == '__main__':
    main()


